<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Menu
 *
 * @author aneto
 */
class NavigationDefaultMenu extends NavigationMenu{
    //put your code here

	public function __construct($arr){
		parent::__construct(array(
			$this->getAction()->getRoute()->getObject(),
			$this->getAction()->getRoute()->getCategoryObject()
		));
	}

	protected function initElements(){
		$q = Doctrine_Query::create()
			->from('Structure s')
			->select('s.*,spg.* , pg.*, pgt.*')
			->where('s.isHidden = ? AND s.level > 1 AND s.lang = ?', array(false,$this->getAbbr()))
			->leftJoin('s.StructureProductGroup spg')
			->leftJoin('spg.ProductGroup pg WITH pg.level = 1')
			->leftJoin('pg.Translation pgt WITH pgt.lang = ?  ', $this->getCulture())
			->setHydrationMode(Doctrine::HYDRATE_ARRAY_HIERARCHY);


		foreach($q->execute() as $index => $elem){ // there is always Structure nodes on the top
			$this->elements[$index] = MenuElement::getInstance($elem, MenuElement::STRUCTURE_NODE, $this, null);
		}



	}
}
